# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sphinxbase
pkgver=5prealpha
pkgrel=3
pkgdesc='Common library for sphinx speech recognition.'
url='http://cmusphinx.sourceforge.net/'
arch=('x86_64' 'aarch64')
license=('BSD')
makedepends=('bison' 'swig')
depends=('python2' 'python' 'lapack' 'libpulse')
source=("http://downloads.sourceforge.net/project/cmusphinx/$pkgname/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('9d999d0b9041c0965ff679636e3c5705987b70317a353916f447809a916878d831a82a5d9c1476d304f908df1ce6b68eb07c906af4f7b86ab84b859ee1b0d20b')
options=('!libtool')

prepare() {
  cd "$pkgname-$pkgver"

  autoreconf -ivf > /dev/null

  cd ..

  cp -R "${pkgname}-${pkgver}" "${pkgname}-${pkgver}-py2"
  cp -R "${pkgname}-${pkgver}" "${pkgname}-${pkgver}-py3"
}

build() {
  cd "${pkgname}-${pkgver}-py2"

  ./configure --prefix=/usr
  make

  cd "../${pkgname}-${pkgver}-py3"

  export PYTHON=/usr/bin/python2
  ./configure --prefix=/usr
  make
}

package() {
  cd "${pkgname}-${pkgver}-py2"

  make DESTDIR="$pkgdir/" install

  cd "../${pkgname}-${pkgver}-py3/swig"
  make DESTDIR="$pkgdir/" install

  install -d "$pkgdir/usr/share/licenses/$pkgname"
  install -m 644 "$srcdir/${pkgname}-${pkgver}/LICENSE" \
                "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

